package org.tloss.web.editor.database.editors.jdbc;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Table {
	private String schemaName;
	private String catalogName;
	private String tableName;
	private String tableType;
	private String remarks;
	private String typeCatalog;
	private String typeSchema;
	private String typeName;
	private String selfReferencingColName;
	private String refGeneration;

	public Table() {

	}

	public Table(Table otherTable) {
		this.schemaName = otherTable.schemaName;
		this.catalogName = otherTable.catalogName;
		this.tableName = otherTable.tableName;
		this.tableType = otherTable.tableType;
		this.remarks = otherTable.remarks;
		this.typeCatalog = otherTable.typeCatalog;
		this.typeSchema = otherTable.typeSchema;
		this.typeName = otherTable.typeName;
		this.selfReferencingColName = otherTable.selfReferencingColName;
		this.refGeneration = otherTable.refGeneration;
	}

	private List<Column> columns;

	@XmlElementWrapper(name = "columns")
	@XmlElement(name = "column")
	public List<Column> getColumns() {
		return columns;
	}

	public void setColumns(List<Column> columns) {
		this.columns = columns;
	}

	@XmlElement
	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	@XmlElement
	public String getTableType() {
		return tableType;
	}

	public void setTableType(String tableType) {
		this.tableType = tableType;
	}

	@XmlElement
	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	@XmlElement
	public String getTypeCatalog() {
		return typeCatalog;
	}

	public void setTypeCatalog(String typeCatalog) {
		this.typeCatalog = typeCatalog;
	}

	@XmlElement
	public String getTypeSchema() {
		return typeSchema;
	}

	public void setTypeSchema(String typeSchema) {
		this.typeSchema = typeSchema;
	}

	@XmlElement
	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	@XmlElement
	public String getSelfReferencingColName() {
		return selfReferencingColName;
	}

	public void setSelfReferencingColName(String selfReferencingColName) {
		this.selfReferencingColName = selfReferencingColName;
	}

	@XmlElement
	public String getRefGeneration() {
		return refGeneration;
	}

	public void setRefGeneration(String refGeneration) {
		this.refGeneration = refGeneration;
	}

	@XmlElement
	public String getSchemaName() {
		return schemaName;
	}

	public void setSchemaName(String schemaName) {
		this.schemaName = schemaName;
	}

	@XmlElement
	public String getCatalogName() {
		return catalogName;
	}

	public void setCatalogName(String catalogName) {
		this.catalogName = catalogName;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((catalogName == null) ? 0 : catalogName.hashCode());
		result = prime * result
				+ ((refGeneration == null) ? 0 : refGeneration.hashCode());
		result = prime * result + ((remarks == null) ? 0 : remarks.hashCode());
		result = prime * result
				+ ((schemaName == null) ? 0 : schemaName.hashCode());
		result = prime
				* result
				+ ((selfReferencingColName == null) ? 0
						: selfReferencingColName.hashCode());
		result = prime * result
				+ ((tableName == null) ? 0 : tableName.hashCode());
		result = prime * result
				+ ((tableType == null) ? 0 : tableType.hashCode());
		result = prime * result
				+ ((typeCatalog == null) ? 0 : typeCatalog.hashCode());
		result = prime * result
				+ ((typeName == null) ? 0 : typeName.hashCode());
		result = prime * result
				+ ((typeSchema == null) ? 0 : typeSchema.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Table other = (Table) obj;
		if (catalogName == null) {
			if (other.catalogName != null)
				return false;
		} else if (!catalogName.equals(other.catalogName))
			return false;
		if (refGeneration == null) {
			if (other.refGeneration != null)
				return false;
		} else if (!refGeneration.equals(other.refGeneration))
			return false;
		if (remarks == null) {
			if (other.remarks != null)
				return false;
		} else if (!remarks.equals(other.remarks))
			return false;
		if (schemaName == null) {
			if (other.schemaName != null)
				return false;
		} else if (!schemaName.equals(other.schemaName))
			return false;
		if (selfReferencingColName == null) {
			if (other.selfReferencingColName != null)
				return false;
		} else if (!selfReferencingColName.equals(other.selfReferencingColName))
			return false;
		if (tableName == null) {
			if (other.tableName != null)
				return false;
		} else if (!tableName.equals(other.tableName))
			return false;
		if (tableType == null) {
			if (other.tableType != null)
				return false;
		} else if (!tableType.equals(other.tableType))
			return false;
		if (typeCatalog == null) {
			if (other.typeCatalog != null)
				return false;
		} else if (!typeCatalog.equals(other.typeCatalog))
			return false;
		if (typeName == null) {
			if (other.typeName != null)
				return false;
		} else if (!typeName.equals(other.typeName))
			return false;
		if (typeSchema == null) {
			if (other.typeSchema != null)
				return false;
		} else if (!typeSchema.equals(other.typeSchema))
			return false;
		return true;
	}

}
